clear all

*set directory

cd "~/replication_files"


* Figure 2: RD plot

use "geo_turnout.dta", clear 


*Figure 2 Effect	
rdrobust turnout_pop euclidean if euclidean<10 & euclidean>-10 

rdrobust turnout_pop running_long if running_long<10 & running_long>-10 

*Figure 2 effect standardized
egen turnout_pop_std=std(turnout_pop), mean(0) std(1)
rdrobust turnout_pop_std running_long if running_long<10 & running_long>-10 
rdrobust turnout_pop_std euclidean if euclidean<10 & euclidean>-10


* Figure A 6 Split states only

rdrobust turnout_pop euclidean if euclidean<10 & euclidean>-10  & state_abbrev=="ID" | state_abbrev=="OR" | state_abbrev=="AZ" ///
	| state_abbrev=="ND" | state_abbrev=="SD" | state_abbrev=="NE" | state_abbrev=="KS" | state_abbrev=="TX" | state_abbrev=="MI" | ///
	state_abbrev=="IN" | state_abbrev=="KY" | state_abbrev=="TN" | state_abbrev=="FL"
	
		
* Figure 3: GRDD and Fixed Effects (By bandwidth)

gen turnout_pop_one=turnout_pop	if running_lat>-0.5 & running_lat<0.5 & running_long>-0.5 & running_long<0.5  
gen turnout_pop_two=turnout_pop	if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1  
gen turnout_pop_three=turnout_pop	if running_lat>-1.5 & running_lat<1.5 & running_long>-1.5 & running_long<1.5  
gen turnout_pop_four=turnout_pop	if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2
gen turnout_pop_five=turnout_pop	if running_lat>-2.5 & running_lat<2.5 & running_long>-2.5 & running_long<2.5  
gen turnout_pop_six=turnout_pop	if running_lat>-3 & running_lat<3 & running_long>-3 & running_long<3
gen turnout_pop_seven=turnout_pop	if running_lat>-3.5 & running_lat<3.5 & running_long>-3.5 & running_long<3.5  
gen turnout_pop_eight=turnout_pop	if running_lat>-4 & running_lat<4 & running_long>-4 & running_long<4
gen turnout_pop_nine=turnout_pop	if running_lat>-4.5 & running_lat<4.5 & running_long>-4.5 & running_long<4.5  
gen turnout_pop_ten=turnout_pop	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5

foreach var in turnout_pop_one turnout_pop_two turnout_pop_three turnout_pop_four turnout_pop_five turnout_pop_six turnout_pop_seven turnout_pop_eight turnout_pop_nine turnout_pop_ten  {
	areg  `var' easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long  ///
	, absorb(state_year)  r 
	scalar `var'=_b[easter_tired_fixed_2]
	scalar `var'_se=_se[easter_tired_fixed_2]
	}
	
	scalar list turnout_pop_one turnout_pop_two turnout_pop_three turnout_pop_four turnout_pop_five turnout_pop_six turnout_pop_seven turnout_pop_eight turnout_pop_nine turnout_pop_ten
	scalar list turnout_pop_one_se turnout_pop_two_se turnout_pop_three_se turnout_pop_four_se turnout_pop_five_se turnout_pop_six_se turnout_pop_seven_se turnout_pop_eight_se turnout_pop_nine_se turnout_pop_ten_se

	areg  turnout_pop_two easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if presidential==1, absorb(state_year)  r 
	areg  turnout_pop_two easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if midterm==1, absorb(state_year)  r 

	// within split states only
	areg  turnout_pop_one easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long  ///
	if  state_abbrev=="ID" | state_abbrev=="OR" | state_abbrev=="AZ" ///
	| state_abbrev=="ND" | state_abbrev=="SD" | state_abbrev=="NE" | state_abbrev=="KS" | state_abbrev=="TX" | state_abbrev=="MI" | ///
	state_abbrev=="IN" | state_abbrev=="KY" | state_abbrev=="TN" | state_abbrev=="FL", absorb(state_year)  r 
	
	areg  turnout_pop_two easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long  ///
	if  state_abbrev=="ID" | state_abbrev=="OR" | state_abbrev=="AZ" ///
	| state_abbrev=="ND" | state_abbrev=="SD" | state_abbrev=="NE" | state_abbrev=="KS" | state_abbrev=="TX" | state_abbrev=="MI" | ///
	state_abbrev=="IN" | state_abbrev=="KY" | state_abbrev=="TN" | state_abbrev=="FL", absorb(state_year)  r 
	
	areg  turnout_pop_ten easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long  ///
	if  state_abbrev=="ID" | state_abbrev=="OR" | state_abbrev=="AZ" ///
	| state_abbrev=="ND" | state_abbrev=="SD" | state_abbrev=="NE" | state_abbrev=="KS" | state_abbrev=="TX" | state_abbrev=="MI" | ///
	state_abbrev=="IN" | state_abbrev=="KY" | state_abbrev=="TN" | state_abbrev=="FL", absorb(state_year)  r 

	
	*Not Early Openers for Polling Times
	areg  turnout_pop_two easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long  if  state_abbrev~="AZ" | state_abbrev~="IL" | state_abbrev~="IN" | state_abbrev~="KY" , absorb(state_year)  r  // 6 am on the border
	areg  turnout_pop_two easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long  if  state_abbrev~="AZ" | state_abbrev~="IL" | state_abbrev~="IN" | state_abbrev~="KY" | state_abbrev~="CT" | state_abbrev~="LA"   | state_abbrev~="ME" | state_abbrev~="MO" | state_abbrev~="NJ" | state_abbrev~="NY"   | state_abbrev~="VA"   , absorb(state_year)  r  // all 
	areg  turnout_pop_two easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long  if  state_abbrev~="AZ" | state_abbrev~="IL" | state_abbrev~="IN" | state_abbrev~="KY" | state_abbrev~="CT" | state_abbrev~="LA"   | state_abbrev~="ME" | state_abbrev~="MO" | state_abbrev~="NJ" | state_abbrev~="NY"   | state_abbrev~="VA"  | state_abbrev~="NC" | state_abbrev~="OH" | state_abbrev~="WV" , absorb(state_year)  r  // all including 6:30 am

	
*Donut RDD
areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if (running_lat<-0.05 & running_lat>-1 | running_lat>0.05 & running_lat<1) & (running_long<-0.05 & running_long>-1 | running_long>0.05 & running_long<1 )  , absorb(state_year)  r 	
	
*Really close to the cutoff: randomization inference + kist really close with no RV 
rdrandinf turnout_pop  running_long 
reg turnout_pop easter_tired_fixed_2 if running_long<0.5 & running_long>-0.5 
reg turnout_pop easter_tired_fixed_2 if running_long<0.1 & running_long>-0.1
reg turnout_pop easter_tired_fixed_2 if running_long<0.1 & running_long>-0.1
	
********** Figure A4: Permutation Tests (Placebo Shuffles) // need to delete the data files manually each time you run
use "geo_turnout.dta", clear 

* No Fixed Effects (delete data file before running) 
set seed 123456789
permute turnout_pop "regress turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long 	if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1" _b, reps(1000) saving("tired1000")

* Fixed Effects (delete data file before running)
set seed 123456789
permute turnout_pop "areg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long 	if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, absorb(state_year)" _b, reps(1000) saving("tired1000_fe")

use "tired1000_fe.dta"
sort b_easter_tired_fixed_2 
saveold "tired1000_fe.dta", replace v(12)

use "tired1000.dta"
sort b_easter_tired_fixed_2
saveold "tired1000.dta", replace v(12)	


	
* Appendix Figure A12 : by rainfall
use "geo_turnout.dta", clear 
drop dup
sort state_fips county_fips year	
quietly by state_fips county_fips year:  gen dup = cond(_N==1,0,_n)
drop if dup>1
merge 1:1 state_fips county_fips year using "merged_vote_rain_both_pres_midterm_pared.dta", gen(_merge_rain_sample)

sum elec_rain_p0, d
gen present_electday_rain=1 if elec_rain_p0>=.25917
replace present_electday_rain=0 if elec_rain_p0<.25917
tab present_electday_rain

sum Lelec_rain_p0, d
gen last_electday_rain=1 if elec_rain_p0>=.31875     
replace last_electday_rain=0 if elec_rain_p0<.31875     
tab last_electday_rain

areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & elec_rain_p0>=.25917 & elec_rain_p0~=., absorb(state_year)  r 
areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & elec_rain_p0<.25917 , absorb(state_year)  r 

*mentioned: larger BW and different level
areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2 & elec_rain_p0>=.25917 & elec_rain_p0~=., absorb(state_year)  r
areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2 & elec_rain_p0<.25917 & elec_rain_p0~=., absorb(state_year)  r


areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & Lelec_rain_p0>=.31875     & Lelec_rain_p0~=., absorb(state_year)  r 
areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & Lelec_rain_p0<.31875    , absorb(state_year)  r

* Mentioned: by Electoral Rules
egen ease_vote = rowmean( absvot earlvot motorvoter pre_reg_state samedayregistration)

sum ease_vote, d

*Split at Median
areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & ease_vote>.2      & Lelec_rain_p0~=., absorb(state_year)  r 
areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & ease_vote<= .2    & Lelec_rain_p0~=. , absorb(state_year)  r



* Figure 5: Heterogeneities

*Narrow bandwidth	
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, quantile(0.9)		
	scalar nine_1=_b[easter_tired_fixed_2]
	scalar nine_se_1=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, quantile(0.8)		
	scalar eight_1=_b[easter_tired_fixed_2]
	scalar eight_se_1=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, quantile(0.7)		
	scalar seven_1=_b[easter_tired_fixed_2]
	scalar seven_se_1=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, quantile(0.6)		
	scalar six_1=_b[easter_tired_fixed_2]
	scalar six_se_1=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, quantile(0.5)		
	scalar five_1=_b[easter_tired_fixed_2]
	scalar five_se_1=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, quantile(0.4)		
	scalar four_1=_b[easter_tired_fixed_2]
	scalar four_se_1=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, quantile(0.3)		
	scalar three_1=_b[easter_tired_fixed_2]
	scalar three_se_1=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, quantile(0.2)		
	scalar two_1=_b[easter_tired_fixed_2]
	scalar two_se_1=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, quantile(0.1)		
	scalar one_1=_b[easter_tired_fixed_2]
	scalar one_se_1=_se[easter_tired_fixed_2]
	
scalar list one_1 two_1 three_1 four_1 five_1 six_1 seven_1 eight_1 nine_1	
scalar list one_se_1 two_se_1 three_se_1 four_se_1 five_se_1 six_se_1 seven_se_1 eight_se_1 nine_se_1	
	

*Wide bandwidth 
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, quantile(0.9)		
	scalar nine_5=_b[easter_tired_fixed_2]
	scalar nine_se_5=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, quantile(0.8)		
	scalar eight_5=_b[easter_tired_fixed_2]
	scalar eight_se_5=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, quantile(0.7)		
	scalar seven_5=_b[easter_tired_fixed_2]
	scalar seven_se_5=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, quantile(0.6)		
	scalar six_5=_b[easter_tired_fixed_2]
	scalar six_se_5=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, quantile(0.5)		
	scalar five_5=_b[easter_tired_fixed_2]
	scalar five_se_5=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, quantile(0.4)		
	scalar four_5=_b[easter_tired_fixed_2]
	scalar four_se_5=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, quantile(0.3)		
	scalar three_5=_b[easter_tired_fixed_2]
	scalar three_se_5=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, quantile(0.2)		
	scalar two_5=_b[easter_tired_fixed_2]
	scalar two_se_5=_se[easter_tired_fixed_2]
qreg turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long  if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, quantile(0.1)		
	scalar one_5=_b[easter_tired_fixed_2]
	scalar one_se_5=_se[easter_tired_fixed_2]
	
scalar list one_5 two_5 three_5 four_5 five_5 six_5 seven_5 eight_5 nine_5	
scalar list one_se_5 two_se_5 three_se_5 four_se_5 five_se_5 six_se_5 seven_se_5 eight_se_5 nine_se_5	
	
	

* Figure 6: vote shares
use "geo_turnout.dta", clear 
drop dup
sort state_fips county_fips year	
quietly by state_fips county_fips year:  gen dup = cond(_N==1,0,_n)
drop if dup>1
merge 1:1 state_fips county_fips year using "merged_vote_rain_both_pres_midterm_pared.dta", gen(_merge_rain_sample)

sum elec_rain_p0, d
gen present_electday_rain=1 if elec_rain_p0>=.25917
replace present_electday_rain=0 if elec_rain_p0<.25917
tab present_electday_rain

sum Lelec_rain_p0, d
gen last_electday_rain=1 if elec_rain_p0>=.31875     
replace last_electday_rain=0 if elec_rain_p0<.31875     
tab last_electday_rain

merge 1:1 state_fips county_fips  year using "House_Election_Data_1992_2014.dta", gen(_merge_elect_outcomes)

* Figure 6


	gen total_two_party=dem_tot+rep_tot
	gen dem_two_party=dem_tot/total_two_party
	
reg  dem_two_party easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, r 	
areg  dem_two_party easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, absorb(state_year)  r 

*mentioned
	
areg  dem_two_party easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & presidential==1, absorb(state_year)  r 
areg  dem_two_party easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & midterm==1, absorb(state_year)  r 

reg  dem_two_party easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2, r 	
areg  dem_two_party easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2, absorb(state_year)  r 



*other specifications

reg  dem_perc easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, r 	
areg  dem_perc easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, absorb(state_year)  r 

egen dem_perc_std=std(dem_perc), mean(0) std(1)
reg  dem_perc_std easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, r 	
areg  dem_perc_std easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, absorb(state_year)  r 


areg  dem_perc easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & presidential==1, absorb(state_year)  r 
areg  dem_perc easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 & midterm==1, absorb(state_year)  r 

reg  dem_perc easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2, r 	
areg  dem_perc easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2, absorb(state_year)  r 




	
	* Figure A11 heterogeneity by incumbency
		sort county_name state_fips year
	gen t0_dem_two_party=dem_two_party[_n-1]
	replace t0_dem_two_party=. if year==1992
	
gen turnout_pop_two=turnout_pop	if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1  
gen turnout_pop_four=turnout_pop	if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2
gen turnout_pop_six=turnout_pop	if running_lat>-3 & running_lat<3 & running_long>-3 & running_long<3
gen turnout_pop_eight=turnout_pop	if running_lat>-4 & running_lat<4 & running_long>-4 & running_long<4
gen turnout_pop_ten=turnout_pop	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5
	
foreach var in turnout_pop_two turnout_pop_four turnout_pop_six turnout_pop_eight turnout_pop_ten  {
	areg  `var' easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if t0_dem_two_party<.5 & dem_two_party!=. ///
	, absorb(state_year)  r 
	scalar `var'=_b[easter_tired_fixed_2]
	scalar `var'_se=_se[easter_tired_fixed_2]
	}
		
	foreach var in turnout_pop_two turnout_pop_four turnout_pop_six turnout_pop_eight turnout_pop_ten  {
	areg  `var' easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if t0_dem_two_party>.5 & dem_two_party!=. ///
	, absorb(state_year)  r 
	scalar `var'=_b[easter_tired_fixed_2]
	scalar `var'_se=_se[easter_tired_fixed_2]
	}	 
	
	areg dem_two_party easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if turnout_pop_two!=. & t0_dem_two_party!=.5, absorb(state_year)  r 
	areg dem_two_party easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if turnout_pop_four!=. & t0_dem_two_party!=.5, absorb(state_year)  r 
	areg dem_two_party easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if turnout_pop_six!=. & t0_dem_two_party!=.5, absorb(state_year)  r 	
	areg dem_two_party easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if turnout_pop_eight!=. & t0_dem_two_party!=.5, absorb(state_year)  r 
	areg dem_two_party easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if turnout_pop_ten!=. & t0_dem_two_party!=.5, absorb(state_year)  r 
	
* covariate balance

drop if county_name==""



drop males females med_age white black ameri_es asian hawn_pi other_race mult_race hispanic 
*(to drop variables from 2010 census and replace them with 2010-2014 ACS)

merge 1:1 county_fips state_fips year using "covariates_census_1992_2014.dta", gen(_merge_decen_census)
sort county_fips state_fips year
capture drop dup
quietly by county_fips state_fips year:  gen dup = cond(_N==1,0,_n)
tab dup
drop if dup>1
merge 1:1 county_fips state_fips year using "migration_flows_merge.dta", gen(_merge_migrations)


gen pop_sqmi= pop90_sqmi
replace pop_sqmi=pop00_sqmi if year==2000 | year==2002 | year==2004 | year==2006 | year==2008
replace pop_sqmi=popACS_10_14_sqmi if year==2010 | year==2012 | year==2014 

drop age_under5 age_5_9 age_10_14 age_15_19 age_20_24 age_25_34 age_35_44 age_45_54 age_55_64 age_65_74 age_75_84 age_85_up med_age_m med_age_f households ave_hh_sz hsehld_1_m hsehld_1_f marhh_chd marhh_no_c mhh_child fhh_child families ave_fam_sz hse_units vacant owner_occ renter_occ no_farms07 avg_size07 crop_acr07 avg_sale07
replace masters_more = masters+ professional_degree+ phd if masters_more==.
replace home_owner = home_owners if home_owner==.
gen more = home_value_500k_750k+ home_value_750k_1m+ home_value_1m_more
replace more=home_value_500k_more if more==.
replace more=home_value_500_750k if more==.
rename more home_value_500k_plus
drop home_value_500k_750k home_value_750k_1m home_value_1m_more home_value_500k_more home_value_500_750k 
gen commute_less_30min= commute_0_10min+ commute_10_20min+ commute_20_30min
replace commute_less_30min= commute_0_5min + commute_5_15min + commute_15_30min if commute_less_30min==.
gen commute_30_60min= commute_30_40min+ commute_40_60min
replace commute_30_60min= commute_30_45min + commute_45_60min if commute_30_60min==.

gen rent_600_1000=rent_600_750+rent_750_1000
replace rent_600_1000=rent_600_800+rent_800_1000 if rent_600_1000==.
replace rent_1000_more= rent_1000_1250 + rent_1250_1500 + rent_1500_2000 + rent_2000_more if rent_1000_more==.



foreach var in totalpopulation pop_sqmi ///
net_migration arrivals  age_0_18 age_18_34 age_35_64 age_65_more ///
 males females white black ameri_es asian hispanic ///
 less_high_school high_school some_college bachelors masters_more ///
 income_per_capita home_owner poverty_yes ///
 commute_less_30min commute_30_60min commute_60_90min commute_90min_more ///
 home_value_0_20k home_value_20_50k home_value_50_100k home_value_100_150k home_value_150_300k home_value_300_500k home_value_500k_plus median_home_value_ACS ///
 rent_0_300 rent_300_600 rent_600_1000 rent_1000_more {
 egen s_`var'=std(`var'), mean(0) std(1)
 }
 


 * Figure A3: covariate balance
 
foreach var in totalpopulation pop_sqmi ///
age_0_18 age_18_34 age_35_64 age_65_more ///
 males females white black ameri_es asian hispanic ///
 less_high_school high_school some_college bachelors masters_more ///
 income_per_capita home_owner poverty_yes ///
 commute_less_30min commute_30_60min commute_60_90min commute_90min_more ///
 home_value_0_20k home_value_20_50k home_value_50_100k home_value_100_150k home_value_150_300k home_value_300_500k home_value_500k_plus  ///
 rent_0_300 rent_300_600 rent_600_1000 rent_1000_more median_home_value_ACS net_migration arrivals  {
	areg  s_`var' easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, absorb(state_year)
	scalar s_`var'=_b[easter_tired_fixed_2]
	scalar s_`var'_se=_se[easter_tired_fixed_2]
 }
 
 * mentioned in appendix
 foreach var in net_migration arrivals  {
	areg  s_`var' easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)
	scalar s_`var'=_b[easter_tired_fixed_2]
	scalar s_`var'_se=_se[easter_tired_fixed_2]
	} 
	
	* joint significance test
		areg easter_tired_fixed_2 s_totalpopulation s_pop_sqmi ///
s_age_0_18 s_age_18_34 s_age_35_64 s_age_65_more ///
 s_males s_females s_white s_black s_ameri_es s_asian s_hispanic ///
 s_less_high_school s_high_school s_some_college s_bachelors s_masters_more ///
 s_income_per_capita s_home_owner s_poverty_yes ///
 s_commute_less_30min s_commute_30_60min s_commute_60_90min s_commute_90min_more ///
 s_home_value_0_20k s_home_value_20_50k s_home_value_50_100k s_home_value_100_150k s_home_value_150_300k s_home_value_300_500k s_home_value_500k_plus  ///
 s_rent_0_300 s_rent_300_600 s_rent_600_1000 s_rent_1000_more s_median_home_value_ACS s_net_migration s_arrivals c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, absorb(state_year)
 test s_totalpopulation s_pop_sqmi ///
s_age_0_18 s_age_18_34 s_age_35_64 s_age_65_more ///
 s_males s_females s_white s_black s_ameri_es s_asian s_hispanic ///
 s_less_high_school s_high_school s_some_college s_bachelors s_masters_more ///
 s_income_per_capita s_home_owner s_poverty_yes ///
 s_commute_less_30min s_commute_30_60min s_commute_60_90min s_commute_90min_more ///
 s_home_value_0_20k s_home_value_20_50k s_home_value_50_100k s_home_value_100_150k s_home_value_150_300k s_home_value_300_500k s_home_value_500k_plus  ///
 s_rent_0_300 s_rent_300_600 s_rent_600_1000 s_rent_1000_more s_median_home_value_ACS s_net_migration s_arrivals
 

 
* Figure A7: GRDD with Controls

reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long 	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 , r 
	scalar one=_b[easter_tired_fixed_2]
	scalar one_se=_se[easter_tired_fixed_2]
reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long 	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 & timezone_eastern==1 , r 
	scalar two=_b[easter_tired_fixed_2]
	scalar two_se=_se[easter_tired_fixed_2]
reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long 	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 & timezone_central==1, r 
	scalar three=_b[easter_tired_fixed_2]
	scalar three_se=_se[easter_tired_fixed_2]
reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long 	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 & timezone_mountain==1, r 
	scalar four=_b[easter_tired_fixed_2]
	scalar four_se=_se[easter_tired_fixed_2]
reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long 	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 & presidential==1, r 
	scalar five=_b[easter_tired_fixed_2]
	scalar five_se=_se[easter_tired_fixed_2]
reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long 	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 & midterm==1, r 
	scalar six=_b[easter_tired_fixed_2]
	scalar six_se=_se[easter_tired_fixed_2]
reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long samedayregistration pre_reg_state earlvot absvot motorvoter	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 , r 
	scalar seven=_b[easter_tired_fixed_2]
	scalar seven_se=_se[easter_tired_fixed_2]	
reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long totalpop pop_sqmi ///
	age_0_18 age_18_34 age_35_64 age_65_more ///
	males females white black ameri_es asian hispanic ///
	less_high_school high_school some_college bachelors masters_more ///
	income_per_capita home_owner poverty_yes ///
	commute_less_30min commute_30_60min commute_60_90min commute_90min_more ///
	home_value_0_20k home_value_20_50k home_value_50_100k home_value_100_150k home_value_150_300k home_value_300_500k home_value_500k_plus ///
	rent_0_300 rent_300_600 rent_600_1000 rent_1000_more if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 , r 
	scalar eight=_b[easter_tired_fixed_2]
	scalar eight_se=_se[easter_tired_fixed_2]
reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long samedayregistration pre_reg_state earlvot absvot motorvoter totalpop pop_sqmi ///
	age_0_18 age_18_34 age_35_64 age_65_more ///
	males females white black ameri_es asian hispanic ///
	less_high_school high_school some_college bachelors masters_more ///
	income_per_capita home_owner poverty_yes ///
	commute_less_30min commute_30_60min commute_60_90min commute_90min_more ///
	home_value_0_20k home_value_20_50k home_value_50_100k home_value_100_150k home_value_150_300k home_value_300_500k home_value_500k_plus ///
	rent_0_300 rent_300_600 rent_600_1000 rent_1000_more if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 , r 
	scalar nine=_b[easter_tired_fixed_2]
	scalar nine_se=_se[easter_tired_fixed_2]	
scalar list one two three four five six seven eight nine
scalar list one_se two_se three_se four_se five_se six_se seven_se eight_se nine_se	

* Figure A8: RD bandwidths without FE

gen turnout_pop_one=turnout_pop	if running_lat>-0.5 & running_lat<0.5 & running_long>-0.5 & running_long<0.5  
gen turnout_pop_three=turnout_pop	if running_lat>-1.5 & running_lat<1.5 & running_long>-1.5 & running_long<1.5  
gen turnout_pop_five=turnout_pop	if running_lat>-2.5 & running_lat<2.5 & running_long>-2.5 & running_long<2.5  
gen turnout_pop_seven=turnout_pop	if running_lat>-3.5 & running_lat<3.5 & running_long>-3.5 & running_long<3.5  
gen turnout_pop_nine=turnout_pop	if running_lat>-4.5 & running_lat<4.5 & running_long>-4.5 & running_long<4.5  


foreach var in turnout_pop_one turnout_pop_two turnout_pop_three turnout_pop_four turnout_pop_five turnout_pop_six turnout_pop_seven turnout_pop_eight turnout_pop_nine turnout_pop_ten  {
	reg  `var' easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long 	, r 
	scalar `var'=_b[easter_tired_fixed_2]
	scalar `var'_se=_se[easter_tired_fixed_2]
	}

foreach var in turnout_pop_one turnout_pop_two turnout_pop_three turnout_pop_four turnout_pop_five turnout_pop_six turnout_pop_seven turnout_pop_eight turnout_pop_nine turnout_pop_ten  {
	scalar list `var'
	}

foreach var in turnout_pop_one turnout_pop_two turnout_pop_three turnout_pop_four turnout_pop_five turnout_pop_six turnout_pop_seven turnout_pop_eight turnout_pop_nine turnout_pop_ten  {
	scalar list `var'_se
	}	
	
	
* Figure A10: GRDD state and year FE, but no interaction 

foreach var in turnout_pop_one turnout_pop_two turnout_pop_three turnout_pop_four turnout_pop_five turnout_pop_six turnout_pop_seven turnout_pop_eight turnout_pop_nine turnout_pop_ten  {
	reg  `var' easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long i.state_fips i.year,  r 
	scalar `var'=_b[easter_tired_fixed_2]
	scalar `var'_se=_se[easter_tired_fixed_2]
	}

foreach var in turnout_pop_one turnout_pop_two turnout_pop_three turnout_pop_four turnout_pop_five turnout_pop_six turnout_pop_seven turnout_pop_eight turnout_pop_nine turnout_pop_ten  {
	scalar list `var'
	}

foreach var in turnout_pop_one turnout_pop_two turnout_pop_three turnout_pop_four turnout_pop_five turnout_pop_six turnout_pop_seven turnout_pop_eight turnout_pop_nine turnout_pop_ten  {
	scalar list `var'_se
	}	
	 
	 
*Figure A5: leave out one state
forvalues i=1(1)56 {
	qui reg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 & state_fips~=`i',  r 
	scalar withhold_b_`i'=_b[easter_tired_fixed_2]
	scalar withhold_se_`i'=_se[easter_tired_fixed_2]
	}
	
forvalues i=1(1)56 {
	scalar list withhold_b_`i'
	}	
	
forvalues i=1(1)56 {
	scalar list withhold_se_`i'
	}	 
	 *Clusters 
	
foreach var in turnout_pop_one turnout_pop_two turnout_pop_three turnout_pop_four turnout_pop_five turnout_pop_six turnout_pop_seven turnout_pop_eight turnout_pop_nine turnout_pop_ten  {
	areg  `var' easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long  ///
	, absorb(state_year) vce(cluster county_fips) 
	scalar `var'=_b[easter_tired_fixed_2]
	scalar `var'_se=_se[easter_tired_fixed_2]
	}
	 
*Leave out one state: split states only with FEs	

gen turnout_pop_split=turnout_pop 

replace turnout_pop_split=. if state_abbrev~="ID" & state_abbrev~="OR" & state_abbrev~="AZ" & state_abbrev~="ND" & state_abbrev~="SD" & state_abbrev~="NE" & state_abbrev~="KS" & ///
	state_abbrev~="TX" & state_abbrev~="MI" & state_abbrev~="IN" & state_abbrev~="KY" & state_abbrev~="TN" & state_abbrev~="FL" 
	
gen state_abbrev_split=state_abbrev if state_abbrev=="ID" | state_abbrev=="OR" | state_abbrev=="AZ" | state_abbrev=="ND" | state_abbrev=="SD" | state_abbrev=="NE" | state_abbrev=="KS" | ///
	state_abbrev=="TX" | state_abbrev=="MI" | state_abbrev=="IN" | state_abbrev=="KY" | state_abbrev=="TN" | state_abbrev=="FL" 
		
encode 	state_abbrev_split, gen(state_abbrev_split_num)
	

forvalues i=1(1)13 {
	areg  turnout_pop_split easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if ///
	running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 & state_abbrev_split_num~=`i', absorb(state_year) r 
	scalar withhold_b_`i'=_b[easter_tired_fixed_2]
	scalar withhold_se_`i'=_se[easter_tired_fixed_2]
	}	
	
forvalues i=1(1)13 {
	scalar list withhold_b_`i'
	}	
	
forvalues i=1(1)13 {
	scalar list withhold_se_`i'
	}	
	

	* Mentioned: drop split counties

	rdrobust turnout_pop running_long if running_long<10 & running_long>-10 & county_name !="Malheur" & county_name!="Idaho" & county_name!="Culberson" & county_name!="Elko" & county_name!="McKenzie" & county_name!="Stanley" & county_name!="Navajo" & county_name!="Apache" & county_name!="Coconino" & county_name!="Cherry"
	areg  turnout_pop_one easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long if county_name !="Malheur" & county_name!="Idaho" & county_name!="Culberson" & county_name!="Elko" & county_name!="McKenzie" & county_name!="Stanley" & county_name!="Navajo" & county_name!="Apache" & county_name!="Coconino" & county_name!="Cherry", absorb(state_year)  r 
		
	
	 
* Figure A9 Voting Age Population

drop dup
order county_name state_fips year
sort county_name state_fips year
quietly by county_name state_fips year:  gen dup = cond(_N==1,0,_n)
drop if dup>1
merge m:1 county_name state_fips year using  "County_total_1992_2002.dta", gen(_merge_county_vap_early)

drop dup
sort county_fips state_fips year
quietly by county_fips state_fips year:  gen dup = cond(_N==1,0,_n)
drop if dup>1
drop if _merge_county_vap_early==2

merge 1:1 county_fips state_fips year using  "County_total_2004_2014.dta", gen(_merge_county_vap_late) update

gen turnout_vap=turnout/cvap_est

drop if turnout_vap>1

areg  turnout_vap easter_tired_fixed_2 c.running_lat c.running_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1, absorb(state_year)  r 

gen turnout_vap_one=turnout_vap	if running_lat>-0.5 & running_lat<0.5 & running_long>-0.5 & running_long<0.5  
gen turnout_vap_two=turnout_vap	if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1  
gen turnout_vap_three=turnout_vap	if running_lat>-1.5 & running_lat<1.5 & running_long>-1.5 & running_long<1.5  
gen turnout_vap_four=turnout_vap	if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2
gen turnout_vap_five=turnout_vap	if running_lat>-2.5 & running_lat<2.5 & running_long>-2.5 & running_long<2.5  
gen turnout_vap_six=turnout_vap	if running_lat>-3 & running_lat<3 & running_long>-3 & running_long<3
gen turnout_vap_seven=turnout_vap	if running_lat>-3.5 & running_lat<3.5 & running_long>-3.5 & running_long<3.5  
gen turnout_vap_eight=turnout_vap	if running_lat>-4 & running_lat<4 & running_long>-4 & running_long<4
gen turnout_vap_nine=turnout_vap	if running_lat>-4.5 & running_lat<4.5 & running_long>-4.5 & running_long<4.5  
gen turnout_vap_ten=turnout_vap	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5

foreach var in turnout_vap_one turnout_vap_two turnout_vap_three turnout_vap_four turnout_vap_five turnout_vap_six turnout_vap_seven turnout_vap_eight turnout_vap_nine turnout_vap_ten  {
	areg  `var' easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long  ///
	, absorb(state_year)  r 
	scalar `var'=_b[easter_tired_fixed_2]
	scalar `var'_se=_se[easter_tired_fixed_2]
	}

	scalar list turnout_vap_one turnout_vap_two turnout_vap_three turnout_vap_four turnout_vap_five turnout_vap_six turnout_vap_seven turnout_vap_eight turnout_vap_nine turnout_vap_ten
scalar list turnout_vap_one_se turnout_vap_two_se turnout_vap_three_se turnout_vap_four_se turnout_vap_five_se turnout_vap_six_se turnout_vap_seven_se turnout_vap_eight_se turnout_vap_nine_se turnout_vap_ten_se


	

	

*Figure 4: WITHIN-COUNTY

use "Kentucky_1948_1990.dta", clear
append using "geo_turnout_just_kentucky.dta" 
append using "Indiana_1948_1990.dta"
append using "geo_turnout_just_indiana.dta" 
replace countyname="St.Joseph" if countyname=="St. Joseph"
replace countyname="DeKalb" if countyname=="Dekalb"

drop if turnout_vap>1


drop presidential	
gen presidential=1 if year==2012 |	year==2008 | year==2004 | year==2000 | year==1996 | year==1992 | year==1988 | year==1984 | year==1980 | year==1976 | year==1972 | year==1968 ///
| year==1964 | year==1960 | year==1956 | year==1952 | year==1948 
replace presidential=0 if presidential==.	
keep if presidential==1

gen turnout_vap_one=turnout_vap	if running_lat>-0.5 & running_lat<0.5 & running_long>-0.5 & running_long<0.5  
gen turnout_vap_two=turnout_vap	if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1  
gen turnout_vap_three=turnout_vap	if running_lat>-1.5 & running_lat<1.5 & running_long>-1.5 & running_long<1.5  
gen turnout_vap_four=turnout_vap	if running_lat>-2 & running_lat<2 & running_long>-2 & running_long<2
gen turnout_vap_five=turnout_vap	if running_lat>-2.5 & running_lat<2.5 & running_long>-2.5 & running_long<2.5  
gen turnout_vap_six=turnout_vap	if running_lat>-3 & running_lat<3 & running_long>-3 & running_long<3
gen turnout_vap_seven=turnout_vap	if running_lat>-3.5 & running_lat<3.5 & running_long>-3.5 & running_long<3.5  
gen turnout_vap_eight=turnout_vap	if running_lat>-4 & running_lat<4 & running_long>-4 & running_long<4
gen turnout_vap_nine=turnout_vap	if running_lat>-4.5 & running_lat<4.5 & running_long>-4.5 & running_long<4.5  
gen turnout_vap_ten=turnout_vap	if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5

foreach var in turnout_vap_one turnout_vap_two turnout_vap_three turnout_vap_four turnout_vap_five turnout_vap_six turnout_vap_seven turnout_vap_eight turnout_vap_nine turnout_vap_ten  {
	areg  `var' easter_tired_fixed_2 c.running_lat c.running_long  east_lat east_long i.year  ///
	, absorb(countyname)  r 
	scalar `var'=_b[easter_tired_fixed_2]
	scalar `var'_se=_se[easter_tired_fixed_2]
	}		
	
	scalar list turnout_vap_one turnout_vap_two turnout_vap_three turnout_vap_four turnout_vap_five turnout_vap_six turnout_vap_seven turnout_vap_eight turnout_vap_nine turnout_vap_ten
scalar list turnout_vap_one_se turnout_vap_two_se turnout_vap_three_se turnout_vap_four_se turnout_vap_five_se turnout_vap_six_se turnout_vap_seven_se turnout_vap_eight_se turnout_vap_nine_se turnout_vap_ten_se




*By Latitude (broken at the median): north vs. south (stays lighter later)
clear
use "geo_turnout.dta", clear 

areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 &  latitude>=38.32668 , absorb(state_year) // north: where latitudinal light swamps time-zone cutoff
areg  turnout_pop easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 &  latitude<38.32668, absorb(state_year) // south: where it stays lighter later
gen north=1 if latitude>=38.32668
replace north=0 if  latitude<38.32668

areg  turnout_pop i.easter_tired_fixed_2##i.north c.running_lat c.running_long east_lat east_long if running_lat>-1 & running_lat<1 & running_long>-1 & running_long<1 , absorb(state_year) // south: where it stays lighter later


	
	
* sleep effects



use "ATUS.dta", clear



by year, sort: sum t010101
gen hours_sleep=t010101/60
by year, sort: sum hours_sleep 

gen less_8=1 if hours_sleep<8
replace less_8=0 if hours_sleep>=8 & hours_sleep~=.

gen less_7=1 if hours_sleep<7
replace less_7=0 if hours_sleep>=7 & hours_sleep~=.


encode state_year, gen(state_year_encode)

gen even_year=1 if year==2004 | year==2006 | year==2008 | year==2010 |  year==2012 | year==2014
replace even_year=0 if even_year==.


egen t010101_std=std(t010101), mean(0) std(1)	

* Figure 7 



areg  t010101 easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)  
	scalar one=_b[easter_tired_fixed_2]
	scalar one_se=_se[easter_tired_fixed_2]	
	
areg  t010101 easter_tired_fixed_2 c.euclidean east_euclidean if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)	
	scalar two=_b[easter_tired_fixed_2]
	scalar two_se=_se[easter_tired_fixed_2]
	

*Different Levels of CLUSTERED SE's
egen county_fips_year=concat(county_fips year)
areg  t010101 easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)  
areg  t010101 easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)  cluster(county_fips)
areg  t010101 easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)   cluster(county_fips_year) // in paper

areg  t010101 easter_tired_fixed_2 c.running_long  east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)  
areg  t010101 easter_tired_fixed_2 c.running_long  east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)  cluster(county_fips)
areg  t010101 easter_tired_fixed_2 c.running_long  east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)  cluster(county_fips_year)  // in paper

areg  less_7 easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)   cluster(county_fips_year) // in paper
areg  less_7 easter_tired_fixed_2 c.running_long  east_long if running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year)  cluster(county_fips_year)  // in paper


	
*Alternate use of time


replace tehruslt  =. if tehruslt  <0
areg  tehruslt easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if  running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year) 
gen tehruslt_min=tehruslt*60
areg  tehruslt_min easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if  running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year) 

gen work_day_average= tehruslt/7
gen work_day_average_mins= work_day_average * 60

areg  work_day_average easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if  running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year) 
areg  work_day_average_mins easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if  running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year) 

*** Time Spent Doing Various Housework Tasks

foreach var in t020101 t020102 t020103 t020104 t020201 t020301 t020302 t020301 t020302 t020303 t020399 t020401 t020402 t020499 t020501 t020502 t020601   t020701 t020799 t020801 t020901 t020902 t020903 t020904 t020905 t020999 t029999 t030101 t030102 t030103 t030104 t030105 t030106 t030108 t030109 t030110 t030111 t030112 t030199 t030201 t030202 t030203 t030299 t030301 t030302 t030303 t030399 t030401 t030402 t030403 t030404 t030405 t030499 t030501 t030502 t030503 t030504 t030599 {
	areg  `var' easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if  running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5 , absorb(state_year) 
}



*** Free Time
gen free_time = 1440 - t010101 /// sleep
	- work_day_average /// work
	- t020101 - t020102 - t020103 - t020104 - t020201 - t020301 - t020302 - t020301 - t020302 - t020303 - t020399 - /// - family/housework - 
	t020401 - t020402 - t020499 - t020501 - t020502 - t020601 - t020701 - t020799 - t020801 - t020901 - t020902 - /// - family/housework
	t020903 - t020904 - t020905 - t020999 - t029999 - t030101 - t030102 - t030103 - t030104 - t030105 - t030106 - /// - family/housework
	t030108 - t030109 - t030110 - t030111 - t030112 - t030199 - t030201 - t030202 - t030203 - t030299 - t030301 - /// - family/housework
	t030302 - t030303 - t030399 - t030401 - t030402 - t030403 - t030404 - t030405 - t030499 - t030501 - t030502 - t030503 - t030504 - t030599
	 
areg  free_time easter_tired_fixed_2 c.running_lat c.running_long east_lat east_long if  running_lat>-5 & running_lat<5 & running_long>-5 & running_long<5, absorb(state_year) 
 	

	
	
